package com.dao.Impl;

import com.dao.UnitDao;
import com.entity.Unit;
import com.util.JDBC;
import com.util.TransBean;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

public class UnitDaoImpl implements UnitDao {

    @Override
    public int add(Unit unit) {
        return 0;
    }

    @Override
    public int modify(Unit unit) {
        return 0;
    }

    @Override
    public int del(int id) {
        return 0;
    }

    @Override
    public List<Unit> findAll() {
        List<Map> maps = JDBC.selectMap("select id,name,status from unit");
        List<Unit> ulist = TransBean.populate(Unit.class, maps);
        return ulist;
    }

    @Override
    public List<Unit> findSctn(int page, int count, String sortBy) {
        return null;
    }

    @Override
    public List<Unit> findByName(String name) {
        return null;
    }

    @Override
    public Unit findById(int id) {
        List<Map> maps = JDBC.selectMap("select id,name,status from unit");
        List<Unit> umap = TransBean.populate(Unit.class, maps);
        if(umap.size()>0){
            return umap.get(0);
        }else{
            return null;
        }
    }
}
